#include("./layout.html")
#@layout()

#define css()
<link href="highlight/styles/railscasts.css" rel="stylesheet">
<link href="https://g.alicdn.com/de/prismplayer/2.9.3/skins/default/aliplayer-min.css" rel="stylesheet"/>
#end

#define script()
<script src="#(CPATH)/static/components/jquery/jquery.form.min.js"></script>
<script src="highlight/highlight.pack.js"></script>

<!-- 阿里云-->
<script src="https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-min.js" type="text/javascript"></script>

<!--类型切换-->
<script>


    /**
     * 创建播放器
     * @param source
     * @returns {Aliplayer}
     */
    function createAliyunPlayer(source, vid, playAuth) {
        if (source !== "") {
            //直播播放器
           return new Aliplayer({
                    "id": "player",
                    "source": source,
                    "width": "100%",
                    "height": "100%",
                    "videoWidth": "100%",
                    "videoHeight": "100%",
                    "autoplay": false,
                    "isLive": true,
                    // "cover": "缩略图",
                    "rePlay": false,
                    "playsinline": true,
                    "preload": false,
                    "controlBarVisibility": "hover",
                    "useH5Prism": true,
                    "useFlashPrism": false
                }, function (player) {
                    console.log("The player is created");
                }
            );
        } else if (vid && playAuth){
            //点播播放器
            return new Aliplayer({
                    "id": "player",
                    "vid": vid,
                    "playauth": playAuth,
                    "width": "100%",
                    "height": "100%",
                    "videoWidth": "100%",
                    "videoHeight": "100%",
                    "autoplay": false,
                    "isLive": false,
                    // "cover": "缩略图",
                    "rePlay": false,
                    "playsinline": true,
                    "preload": false,
                    "controlBarVisibility": "hover",
                    "useH5Prism": true
                }, function (player) {
                    console.log("The player is created");
                }
            );

        }
    }

    createAliyunPlayer("#(livePlayUrl ??)", "#(cloudVid ??)", "#(cloudPlayAuth ??)")


</script>
<!--阿里云 end-->

<script>

    hljs.initHighlightingOnLoad();

</script>
#end


#define content()
<div class="container bl-container">
    <div class="row">
        <div class="col-md-9 col-sm-12">
            <h3 class="bl-article-title">
                #(video.title ??)
            </h3>

            <div class="bl-article-label">
                <div class="article-label-item">
                    <img src="#(video.user.avatar ??)" class="img-fluid rounded-circle bl-img-size" alt="">
                    <span class="text-surmary">#(video.user.nickname ??)</span>
                </div>

                <div class="article-label-item">#date(video.created)</div>
            </div>
            <div class="bl-article ck-content">
                #(video.content ??)
            </div>
            <div class="bl-article ck-content">
                <div class="form-group row">
                    <div class="col-sm-6">
                        #if("aliyun" == video.cloudType)
                        <!--  阿里云视频播放容器  -->
                        <div id="aliyunPlayerContainer">
                            <div class="pr-0 bg-gray" id="player" style="height: 350px;"></div>
                        </div>
                        #else
                        <!--  本地视频 或者 自定义第三方 播放容器  -->
                        <div id="localPlayerContainer">
                            <video class=" pr-0 bg-gray" controls="controls" id="localPlay" src="#(video.playUrl ??)"
                                   poster="#(video.cover ??)"
                                   style="height: 350px;width: 700px;"></video>
                        </div>
                        #end
                    </div>
                </div>


            </div>

            #relevantVideos(video)
            <div class="recommend-panel">
                <h4 class="bl-title">相关视频</h4>
                <div class="card-deck">
                    #for(video :relevantVideos )
                    <div class="card card-outlinebl-panel">
                        <a class="recommend-panel-link" href="#(video.url ??)">
                            <div class="recommend-panel-top">
                                <img src="#(video.showImage ?? 'img/blog-image.jpg')" class="img-fluid"
                                     alt="#(video.title ??)">
                            </div>
                            <div class="recommend-panel-bottom">
                                #(video.title ??)
                            </div>
                        </a>
                    </div>
                    #end
                </div>
            </div>
            #end

        </div>



        <div class="col-md-3 col-sm-12">
            <div class="card-right">
                <h4 class="bl-title">热门视频</h4>

                #videos()
                #for(video : videos)
                <div class="card-right-body">
                    <a href="#(video.url ??)">
                        <div>
                            <img src="#(video.cover ?? 'img/default-img.jpg')"
                                 class="img-fluid"
                                 alt="#(video.title ??)">

                        </div>
                        <p>#(video.title ??)</p>
                    </a>
                </div>
                #end
                #end

            </div>
        </div>
    </div>
</div>
#end